
export default {
  fullScreen() {
    var element = document.documentElement
    if (window.ActiveXObject) {
      var WsShell = new ActiveXObject('WScript.Shell')
      WsShell.SendKeys('{F11}')
    } else if (element.requestFullScreen) {
      element.requestFullScreen()
    } else if (element.msRequestFullscreen) {
      element.msRequestFullscreen()
    } else if (element.webkitRequestFullScreen) {
      element.webkitRequestFullScreen()
    } else if (element.mozRequestFullScreen) {
      element.mozRequestFullScreen()
    }
  },
  fullExit() {
    var element = document.documentElement
    if (window.ActiveXObject) {
      var WsShell = new ActiveXObject('WScript.Shell')
      WsShell.SendKeys('{F11}')
    } else if (element.requestFullScreen) {
      document.exitFullscreen()
    } else if (element.msRequestFullscreen) {
      document.msExitFullscreen()
    } else if (element.webkitRequestFullScreen) {
      document.webkitCancelFullScreen()
    } else if (element.mozRequestFullScreen) {
      document.mozCancelFullScreen()
    }
  },
  utcToLocal(time) {
    let formatNum = (num)=>{
        return num>=10?num:('0'+num)
    }
    let arr = time.split(/[^0-9]/)
    let worldDate = new Date(arr[0], arr[1] - 1, arr[2], arr[3], arr[4], arr[5])
    let localDate = new Date(worldDate.getTime() + 8 * 60 * 60 * 1000)
    return formatNum(localDate.getFullYear()) + "-"
        + formatNum((localDate.getMonth() + 1)) + "-" 
        + formatNum(localDate.getDate()) + " " 
        + formatNum(localDate.getHours()) + ":" 
        + formatNum(localDate.getMinutes()) + ":" 
        + formatNum(localDate.getSeconds())
  },
  formatTime(time) {
    let it = parseInt(time)
    let m = parseInt(it / 60)
    let s = parseInt(it % 60)

    return (m < 10 ? "0" : "") + parseInt(it / 60) + ":" + (s < 10 ? "0" : "") + parseInt(it % 60)
  }
}